<?php

/**
 * This is the model class for table "{{mobile_brand}}".
 *
 * The followings are the available columns in table '{{mobile_brand}}':
 * @property integer $moeb_id
 * @property integer $moeb_order
 * @property string $moeb_name
 * @property string $moeb_log
 * @property integer $moeb_is_recomment
 */
class MobileBrand extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return MobileBrand the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{mobile_brand}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('moeb_name', 'required'),
			array('moeb_order, moeb_is_recomment', 'numerical', 'integerOnly'=>true),
			array('moeb_name', 'length', 'max'=>32),
			array('moeb_log', 'length', 'max'=>100),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('moeb_id, moeb_order, moeb_name, moeb_log, moeb_is_recomment', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'moeb_id' => '品牌标识号',
			'moeb_order' => '品牌排列顺序',
			'moeb_name' => '品牌名称',
			'moeb_log' => '品牌log',
			'moeb_is_recomment' => '是否为推荐品牌',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

//		$criteria->compare('moeb_id',$this->moeb_id);

//		$criteria->compare('moeb_order',$this->moeb_order);

		$criteria->compare('moeb_name',$this->moeb_name,true);

//		$criteria->compare('moeb_log',$this->moeb_log,true);

		$criteria->compare('moeb_is_recomment',$this->moeb_is_recomment);

		return new CActiveDataProvider('MobileBrand', array(
			'criteria'=>$criteria,
		));
	}
}